/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.icee.myth.server.pipelineFactory;

import com.icee.myth.common.encoder.Type4BytesLengthFieldProtobufEncoder;
import com.icee.myth.server.channelHandler.ManagerConnectHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;


/**
 * 服务器与服务器通信，Manager服务器作为客户端，链接游戏服务器（作为服务器）的管理初始化处理
 *
 * @author liuxianke
 */
public class ManagerConnectGameServerPipelineInitializer extends ChannelInitializer<SocketChannel> {

    public ManagerConnectGameServerPipelineInitializer() {}

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
        ch.pipeline().addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 0, 0));
        ch.pipeline().addLast("customEncoder", new Type4BytesLengthFieldProtobufEncoder());
        ch.pipeline().addLast("managerConnectHandler", new ManagerConnectHandler());
    }

}
